package br.com.viewcar.service;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.viewcar.entity.Area;
import br.com.viewcar.util.CheckrotaUtil;

@Repository
@Transactional
public class AreaService extends BaseService<Integer,Area> {

	@Override
	@Transactional
	public Area save(Area area) {
		area.setStatus(true);
		return super.save(area);
	}

	@Override
	@Transactional
	public Area delete(Integer id) {

		Area area = retrieve(id);
		area.setStatus(false);
		update(area);
		return area;
	}

	@Override
	@Transactional(readOnly = true)
	public List<Area> retrieveAll() {

		if(CheckrotaUtil.isAdministradorSistema()) {
			return executeResultListQuery("findAll");
		}
		return null;
	}
}